﻿#region License
// Copyright © 2004 - 2010 All Right Reserved, Derek Goslin
// 
// 1. Definitions
// The terms "reproduce," "reproduction," "derivative works," and "distribution" have the same meaning here as under U.S. copyright law.
// A "contribution" is the original software, or any additions or changes to the software.
// A "contributor" is any person that distributes its contribution under this license.
// "Licensed patents" are a contributor's patent claims that read directly on its contribution.
// 
// 2. Grant of Rights
// (A) Copyright Grant- Subject to the terms of this license, including the license
//     conditions and limitations in section 3, each contributor grants you a non-exclusive,
//     worldwide, royalty-free copyright license to reproduce its contribution, prepare derivative 
//     works of its contribution, and distribute its contribution or any derivative works that you create.
// (B) Patent Grant- Subject to the terms of this license, including the license conditions and limitations
//     in section 3, each contributor grants you a non-exclusive, worldwide, royalty-free license under its
//     licensed patents to make, have made, use, sell, offer for sale, import, and/or otherwise dispose of
//     its contribution in the software or derivative works of the contribution in the software.
// 
// 3. Conditions and Limitations
// (A) Reciprocal Grants- For any file you distribute that contains code from the software (in source code or binary format), 
//     you must provide recipients the source code to that file along with a copy of this license, which license will govern that file. 
//     You may license other files that are entirely your own work and do not contain code from the software under any terms you choose.
// (B) No Trademark License- This license does not grant you rights to use any contributors' name, logo, or trademarks.
// (C) If you bring a patent claim against any contributor over patents that you claim are infringed by the software,
//     your patent license from such contributor to the software ends automatically.
// (D) If you distribute any portion of the software, you must retain all copyright, patent, trademark,
//     and attribution notices that are present in the software.
// (E) If you distribute any portion of the software in source code form, you may do so only under this license by including a complete copy 
//     of this license with your distribution. If you distribute any portion of the software in compiled or object code form, you may only do 
//     so under a license that complies with this license.
// (F) The software is licensed "as-is." You bear the risk of using it. The contributors give no express warranties, guarantees or conditions.
//    You may have additional consumer rights under your local laws which this license cannot change. To the extent permitted under your
//    local laws, the contributors exclude the implied warranties of merchantability, fitness for a particular purpose and non-infringement.
#endregion

using System;
using DnEcuDiag.Ecus.Enums;
using DnEcuDiag.Ecus.Generic;
using DnEcuDiag.Ecus.Kwp;
using DnEcuDiag.Factories;
using NUnit.Framework;

namespace DnEcuDiag.Tests
{
    [TestFixture]
    public class M155Tests
    {
        private KwpEcu _ecu;
        private KwpTestDevice _device;

        [TestFixtureSetUp]
        public void TestSetup()
        {
            _device = new KwpTestDevice();

            EcuDescriptor descriptor = EcuFactory.EcuList.Find(ecuDescriptor => ecuDescriptor.Name == "Bosch Motronic M1.5.5");

            _ecu = EcuFactory.CreateEcu(descriptor) as KwpEcu;
            Assert.IsNotNull(_ecu);
            _ecu.DiagnosticInterface = _device;
            _ecu.Connect();
        }

        [Test]
        public void TestIdentification()
        {
            Assert.AreEqual("Bosch Motronic M1.5.5", _ecu.Model);
            Assert.AreEqual("0123456789 ", _ecu.DrawingNumber);
            Assert.AreEqual("0123456789 ", _ecu.HardwareNumber);
            Assert.AreEqual("0x10", _ecu.HardwareVersionNumber);
            Assert.AreEqual("0123456789 ", _ecu.SoftwareNumber);
            Assert.AreEqual("0x85170", _ecu.SoftwareVersionNumber);
            Assert.AreEqual("01234 ", _ecu.OmologationNumber);
            Assert.AreEqual("55 AA 55 AA 55 ", _ecu.IsoCode);
            Assert.AreEqual("19 97 03 31 ", _ecu.ProductionDate);
            Assert.AreEqual("19 97 03 31 ", _ecu.ProgrammingDate);
            Assert.IsNotNull(_ecu.RpmSensor);
            Assert.AreEqual("Engine Speed", _ecu.RpmSensor.Name);
            Assert.IsNotNull(_ecu.SpeedSensor);
            Assert.AreEqual("Vehicle Speed (Low Res)", _ecu.SpeedSensor.Name);
            Assert.AreEqual(InitType.Extended, _ecu.InitType);
        }

        [Test]
        public void TestFaults()
        {
            Assert.AreNotEqual(0, _ecu.ErrorMemoryStructureDefinition.ErrorDefinitions.Count, "_ecu.ErrorMemoryStructureDefinition.Count == 0 for M.1.5.5");
            Assert.AreEqual(37, _ecu.ErrorMemoryStructureDefinition.ErrorDefinitions.Count, "_ecu.ErrorMemoryStructureDefinition.Count != 37 for M.1.5.5");

            //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
            // Three P0100
            //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////			
            _device.FaultcodeList = new byte[] { 0x58, 03, 01, 00, 0xE2, 01, 00, 0xE2, 01, 00, 0xE2 };
            _device.Faultcodeinfo = new byte[13] { 0x61, 0x10, 0x01, 0x00, 0xE2, 0x1D, 0x0D, 0x00, 0x00, 0x00, 0x00, 0x40, 0x00 };
            _ecu.ReadFaultCodes();

            Assert.AreEqual(3, _ecu.ActiveFaultCodes.Count, "_ecu.ActiveFaultCodes.Count == 3 for M.1.5.5");
            Console.WriteLine(_ecu.ActiveFaultCodes[0].FaultDescription);
            Assert.AreEqual("P0100", (_ecu.ActiveFaultCodes[0]).FaultComponent);
            Assert.AreEqual("Failed Component Code: Air Flow Meter\r\nFault Symptom: Short Circuit Gnd/Open Circuit\r\nWarning Lamp Status: Warning Lamp Illuminated\r\nFault Test State: Test complete for this Error or not applicable.\r\nFault Code Storage State: Error Present at time of request\r\nEvent Count: 64 count\r\nFilter Count: 0 count\r\nEnvironmental Condition One: Engine Speed: 1160 rpm\r\nEnvironmental Condition Two: Throttle Valve Angle: 6.1 °\r\n",
                _ecu.ActiveFaultCodes[0].FaultDescription);

            //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
            // One P0110
            //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
            _device.FaultcodeList = new byte[] { 0x58, 01, 0x01, 0x10, 0xE1 };
            _device.Faultcodeinfo = new byte[13] { 0x61, 0x10, 0x01, 0x10, 0xE1, 0x1D, 0x0D, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF };
            _ecu.ReadFaultCodes();

            // Test collection.
            Assert.AreEqual(1, _ecu.ActiveFaultCodes.Count, "_ecu.ActiveFaultCodes.Count == 1 for M.1.5.5");
            Assert.AreEqual("P0110", (_ecu.ActiveFaultCodes[0]).FaultComponent);
            Console.WriteLine(_ecu.ActiveFaultCodes[0].FaultDescription);
            Assert.AreEqual("Failed Component Code: Air Temperature Sensor\r\nFault Symptom: Short Circuit VBatt/Open Circuit\r\nWarning Lamp Status: Warning Lamp Illuminated\r\nFault Test State: Test complete for this Error or not applicable.\r\nFault Code Storage State: Error Present at time of request\r\nEvent Count: 255 count\r\nFilter Count: 255 count\r\nEnvironmental Condition One: Engine Speed: 1160 rpm\r\nEnvironmental Condition Two: Engine Coolant Temperature: -25.4 °C\r\n",
                _ecu.ActiveFaultCodes[0].FaultDescription);


            _device.FaultcodeList = new byte[] { 0x58, 01, 01, 0x10, 0xE2 };
            _device.Faultcodeinfo = new byte[13] { 0x61, 0x10, 0x01, 0x10, 0xE2, 0x1D, 0x0D, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF };
            _ecu.ReadFaultCodes();

            Assert.AreEqual(1, _ecu.ActiveFaultCodes.Count, "_ecu.ActiveFaultCodes.Count == 1 for M.1.5.5");
            Assert.AreEqual("P0110", (_ecu.ActiveFaultCodes[0]).FaultComponent);
            Console.WriteLine(_ecu.ActiveFaultCodes[0].FaultDescription);
            Assert.AreEqual("Failed Component Code: Air Temperature Sensor\r\nFault Symptom: Short Circuit Gnd\r\nWarning Lamp Status: Warning Lamp Illuminated\r\nFault Test State: Test complete for this Error or not applicable.\r\nFault Code Storage State: Error Present at time of request\r\nEvent Count: 255 count\r\nFilter Count: 255 count\r\nEnvironmental Condition One: Engine Speed: 1160 rpm\r\nEnvironmental Condition Two: Engine Coolant Temperature: -25.4 °C\r\n",
                _ecu.ActiveFaultCodes[0].FaultDescription);

            //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
            // One P0115
            //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
            _device.FaultcodeList = new byte[] { 0x58, 01, 01, 0x15, 0xE1 };
            _device.Faultcodeinfo = new byte[13] { 0x61, 0x10, 0x01, 0x15, 0xE1, 0x1D, 0x0D, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF };
            _ecu.ReadFaultCodes();

            Assert.AreEqual(1, _ecu.ActiveFaultCodes.Count, "_ecu.ActiveFaultCodes.Count == 1 for M.1.5.5");
            Assert.AreEqual("P0115", (_ecu.ActiveFaultCodes[0]).FaultComponent);
            Console.WriteLine(_ecu.ActiveFaultCodes[0].FaultDescription);
            Assert.AreEqual("Failed Component Code: Engine Temperature Sensor\r\nFault Symptom: Short Circuit VBatt/Open Circuit\r\nWarning Lamp Status: Warning Lamp Illuminated\r\nFault Test State: Test complete for this Error or not applicable.\r\nFault Code Storage State: Error Present at time of request\r\nEvent Count: 255 count\r\nFilter Count: 255 count\r\nEnvironmental Condition One: Engine Speed: 1160 rpm\r\nEnvironmental Condition Two: Filtered Load: 650 uS\r\n",
                _ecu.ActiveFaultCodes[0].FaultDescription);

            _device.FaultcodeList = new byte[] { 0x58, 01, 01, 0x15, 0xE2 };
            _device.Faultcodeinfo = new byte[13] { 0x61, 0x10, 0x01, 0x15, 0xE2, 0x1D, 0x0D, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF };
            _ecu.ReadFaultCodes();

            Assert.AreEqual(1, _ecu.ActiveFaultCodes.Count, "_ecu.ActiveFaultCodes.Count == 1 for M.1.5.5");
            Assert.AreEqual("P0115", (_ecu.ActiveFaultCodes[0]).FaultComponent);
            Console.WriteLine(_ecu.ActiveFaultCodes[0].FaultDescription);
            Assert.AreEqual("Failed Component Code: Engine Temperature Sensor\r\nFault Symptom: Short Circuit Gnd\r\nWarning Lamp Status: Warning Lamp Illuminated\r\nFault Test State: Test complete for this Error or not applicable.\r\nFault Code Storage State: Error Present at time of request\r\nEvent Count: 255 count\r\nFilter Count: 255 count\r\nEnvironmental Condition One: Engine Speed: 1160 rpm\r\nEnvironmental Condition Two: Filtered Load: 650 uS\r\n",
                _ecu.ActiveFaultCodes[0].FaultDescription);

            _device.FaultcodeList = new byte[] { 0x58, 01, 01, 0x15, 0xE8 };
            _device.Faultcodeinfo = new byte[13] { 0x61, 0x10, 0x01, 0x15, 0xE8, 0x1D, 0x0D, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF };
            _ecu.ReadFaultCodes();

            Assert.AreEqual(1, _ecu.ActiveFaultCodes.Count, "_ecu.ActiveFaultCodes.Count == 1 for M.1.5.5");
            Assert.AreEqual("P0115", (_ecu.ActiveFaultCodes[0]).FaultComponent);
            Console.WriteLine(_ecu.ActiveFaultCodes[0].FaultDescription);
            Assert.AreEqual("Failed Component Code: Engine Temperature Sensor\r\nFault Symptom: Signal Not Plausible\r\nWarning Lamp Status: Warning Lamp Illuminated\r\nFault Test State: Test complete for this Error or not applicable.\r\nFault Code Storage State: Error Present at time of request\r\nEvent Count: 255 count\r\nFilter Count: 255 count\r\nEnvironmental Condition One: Engine Speed: 1160 rpm\r\nEnvironmental Condition Two: Filtered Load: 650 uS\r\n",
                _ecu.ActiveFaultCodes[0].FaultDescription);

            //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
            // One P0120
            //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
            _device.FaultcodeList = new byte[] { 0x58, 01, 01, 0x20, 0xE1 };
            _device.Faultcodeinfo = new byte[13] { 0x61, 0x10, 0x01, 0x20, 0xE1, 0x1D, 0x0D, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF };
            _ecu.ReadFaultCodes();

            Assert.AreEqual(1, _ecu.ActiveFaultCodes.Count, "_ecu.ActiveFaultCodes.Count == 1 for M.1.5.5");
            Assert.AreEqual("P0120", (_ecu.ActiveFaultCodes[0]).FaultComponent);
            Console.WriteLine(_ecu.ActiveFaultCodes[0].FaultDescription);
            Assert.AreEqual("Failed Component Code: Throttle Valve Potentiometer\r\nFault Symptom: Short Circuit VBatt\r\nWarning Lamp Status: Warning Lamp Illuminated\r\nFault Test State: Test complete for this Error or not applicable.\r\nFault Code Storage State: Error Present at time of request\r\nEvent Count: 255 count\r\nFilter Count: 255 count\r\nEnvironmental Condition One: Engine Speed: 1160 rpm\r\nEnvironmental Condition Two: Battery Voltage: 0.94 volts\r\n",
                _ecu.ActiveFaultCodes[0].FaultDescription);

            _device.FaultcodeList = new byte[] { 0x58, 01, 01, 0x20, 0xE2 };
            _device.Faultcodeinfo = new byte[13] { 0x61, 0x10, 0x01, 0x20, 0xE2, 0x1D, 0x0D, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF };
            _ecu.ReadFaultCodes();

            Assert.AreEqual(1, _ecu.ActiveFaultCodes.Count, "_ecu.ActiveFaultCodes.Count == 1 for M.1.5.5");
            Assert.AreEqual("P0120", (_ecu.ActiveFaultCodes[0]).FaultComponent);
            Console.WriteLine(_ecu.ActiveFaultCodes[0].FaultDescription);
            Assert.AreEqual("Failed Component Code: Throttle Valve Potentiometer\r\nFault Symptom: Short Circuit Gnd\r\nWarning Lamp Status: Warning Lamp Illuminated\r\nFault Test State: Test complete for this Error or not applicable.\r\nFault Code Storage State: Error Present at time of request\r\nEvent Count: 255 count\r\nFilter Count: 255 count\r\nEnvironmental Condition One: Engine Speed: 1160 rpm\r\nEnvironmental Condition Two: Battery Voltage: 0.94 volts\r\n",
                _ecu.ActiveFaultCodes[0].FaultDescription);

            //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
            // One P0135
            //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
            _device.FaultcodeList = new byte[] { 0x58, 01, 01, 0x35, 0xE2 };
            _device.Faultcodeinfo = new byte[13] { 0x61, 0x10, 0x01, 0x35, 0xE2, 0x1D, 0x0D, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF };
            _ecu.ReadFaultCodes();

            Assert.AreEqual(1, _ecu.ActiveFaultCodes.Count, "_ecu.ActiveFaultCodes.Count == 1 for M.1.5.5");
            Assert.AreEqual("P0135", (_ecu.ActiveFaultCodes[0]).FaultComponent);
            Console.WriteLine(_ecu.ActiveFaultCodes[0].FaultDescription);
            Assert.AreEqual("Failed Component Code: Lambda Sensor One Heater\r\nFault Symptom: Resistance Below Minimum Limit\r\nWarning Lamp Status: Warning Lamp Illuminated\r\nFault Test State: Test complete for this Error or not applicable.\r\nFault Code Storage State: Error Present at time of request\r\nEvent Count: 255 count\r\nFilter Count: 255 count\r\n",
                _ecu.ActiveFaultCodes[0].FaultDescription);


            //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
            // One P0335
            //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
            _device.FaultcodeList = new byte[] { 0x58, 01, 03, 0x35, 0xE4 };
            _device.Faultcodeinfo = new byte[13] { 0x61, 0x10, 0x03, 0x35, 0xE4, 0x1D, 0x0D, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF };
            _ecu.ReadFaultCodes();

            Assert.AreEqual(1, _ecu.ActiveFaultCodes.Count, "_ecu.ActiveFaultCodes.Count == 1 for M.1.5.5");
            Assert.AreEqual("P0335", (_ecu.ActiveFaultCodes[0]).FaultComponent);
            Console.WriteLine(_ecu.ActiveFaultCodes[0].FaultDescription);
            Assert.AreEqual("Failed Component Code: RPM sensor\r\nFault Symptom: Open Circuit\r\nWarning Lamp Status: Warning Lamp Illuminated\r\nFault Test State: Test complete for this Error or not applicable.\r\nFault Code Storage State: Error Present at time of request\r\nEvent Count: 255 count\r\nFilter Count: 255 count\r\nEnvironmental Condition One: Battery Voltage: 2.1 volts\r\nEnvironmental Condition Two: Engine Coolant Temperature: -25.4 °C\r\n",
                _ecu.ActiveFaultCodes[0].FaultDescription);


            //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
            // One P1654
            //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
            _device.FaultcodeList = new byte[] { 0x58, 01, 0x16, 0x54, 0xE4 };
            _device.Faultcodeinfo = new byte[13] { 0x61, 0x10, 0x16, 0x54, 0xE4, 0x1D, 0x0D, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF };
            _ecu.ReadFaultCodes();

            Assert.AreEqual(1, _ecu.ActiveFaultCodes.Count, "_ecu.ActiveFaultCodes.Count == 1 for M.1.5.5");
            Assert.AreEqual("P1654", (_ecu.ActiveFaultCodes[0]).FaultComponent);
            Console.WriteLine(_ecu.ActiveFaultCodes[0].FaultDescription);
            Assert.AreEqual("Failed Component Code: Modular Manifold\r\nFault Symptom: Circuit Open\r\nWarning Lamp Status: Warning Lamp Illuminated\r\nFault Test State: Test complete for this Error or not applicable.\r\nFault Code Storage State: Error Present at time of request\r\nEvent Count: 255 count\r\nFilter Count: 255 count\r\nEnvironmental Condition One: Engine Speed: 1160 rpm\r\nEnvironmental Condition Two: Engine Coolant Temperature: -25.4 °C\r\n",
                _ecu.ActiveFaultCodes[0].FaultDescription);

            //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
            // One P0655
            //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
            _device.FaultcodeList = new byte[] { 0x58, 01, 0x06, 0x55, 0xE4 };
            _device.Faultcodeinfo = new byte[13] { 0x61, 0x10, 0x06, 0x55, 0xE4, 0x1D, 0x0D, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF };
            _ecu.ReadFaultCodes();

            Assert.AreEqual(1, _ecu.ActiveFaultCodes.Count, "_ecu.ActiveFaultCodes.Count == 1 for M.1.5.5");
            Assert.AreEqual("P0655", (_ecu.ActiveFaultCodes[0]).FaultComponent);
            Console.WriteLine(_ecu.ActiveFaultCodes[0].FaultDescription);
            Assert.AreEqual("Failed Component Code: High Temperature Warning Light\r\nFault Symptom: Circuit Open\r\nWarning Lamp Status: Warning Lamp Illuminated\r\nFault Test State: Test complete for this Error or not applicable.\r\nFault Code Storage State: Error Present at time of request\r\nEvent Count: 255 count\r\nFilter Count: 255 count\r\nEnvironmental Condition One: Engine Speed: 1160 rpm\r\nEnvironmental Condition Two: Engine Coolant Temperature: -25.4 °C\r\n",
                _ecu.ActiveFaultCodes[0].FaultDescription);

            //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
            // U1600
            //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////			
            _device.FaultcodeList = new byte[] { 0x58, 0x01, 0xD6, 0x00, 0xE8 };
            _device.Faultcodeinfo = new byte[13] { 0x61, 0x10, 0xD6, 0x01, 0xE8, 0x1D, 0xFF, 0xFF, 0xFF, 0xA, 0x0A, 0x40, 0x00 };
            _ecu.ReadFaultCodes();

            Assert.AreEqual(1, _ecu.ActiveFaultCodes.Count, "_ecu.ActiveFaultCodes.Count == 1 for M.1.5.5");
            Console.WriteLine(_ecu.ActiveFaultCodes[0].FaultDescription);
            Assert.AreEqual("U1600", (_ecu.ActiveFaultCodes[0]).FaultComponent);
            Assert.AreEqual("Failed Component Code: Immobiliser\r\nFault Symptom: Signal Not Plausible\r\n" +
                "Warning Lamp Status: Warning Lamp Illuminated\r\nFault Test State: Test complete for this Error or not applicable." +
                "\r\nFault Code Storage State: Error Present at time of request\r\nEvent Count: 64 count\r\n" +
                "Filter Count: 0 count\r\n" +
                "Environmental Condition One: Immobiliser: Not ok\r\n" +
                "Environmental Condition One: Immobiliser: No code received or link interrupted\r\n" +
                "Environmental Condition One: Immobiliser: Erroneous key code\r\n" +
                "Environmental Condition One: Immobiliser: Virgin Ecu\r\n" +
                "Environmental Condition One: Immobiliser: Engine Start Disabled\r\n" +
                "Environmental Condition One: Immobiliser: Universal Code Received\r\n" +
                "Environmental Condition Two: Battery Voltage: 18.44 volts\r\n",
                _ecu.ActiveFaultCodes[0].FaultDescription);
        }

        [Test]
        public void TestSensors()
        {
            Assert.AreEqual(51, _ecu.Sensors.Count);

            TestSensorValues();
        }
        private void TestSensorValues()
        {
            TimeStampedMeasurement tsm;
            int i = 0;

            LocalIdentifier li = _ecu.Sensors[i] as LocalIdentifier;
            _device.LocalidentifierData = new byte[] { 0x61, (Byte)li.Id, 0x00, 01 };

            Console.WriteLine(string.Format("Testing Sensor: [{0}] {1}", i, _ecu.Sensors[i].Name));
            tsm = _ecu.ReadSensor(_ecu.Sensors[i]);
            Assert.AreEqual("True", tsm.Status);
            Assert.AreEqual(1, tsm.Measurement);

            _device.LocalidentifierData = new byte[] { 0x61, (Byte)li.Id, 0x00, 00 };

            tsm = _ecu.ReadSensor(_ecu.Sensors[i]);
            Assert.AreEqual("False", tsm.Status);
            Assert.AreEqual(0, tsm.Measurement);

            i++;

            li = _ecu.Sensors[i] as LocalIdentifier;
            _device.LocalidentifierData = new byte[] { 0x61, (Byte)li.Id, 0x00, 02 };

            Console.WriteLine(string.Format("Testing Sensor: [{0}] {1}", i, _ecu.Sensors[i].Name));
            tsm = _ecu.ReadSensor(_ecu.Sensors[i]);
            Assert.AreEqual("True", tsm.Status);
            Assert.AreEqual(1, tsm.Measurement);

            _device.LocalidentifierData = new byte[] { 0x61, (Byte)li.Id, 0x00, 00 };

            tsm = _ecu.ReadSensor(_ecu.Sensors[i]);
            Assert.AreEqual("False", tsm.Status);
            Assert.AreEqual(0, tsm.Measurement);

            i++;

            li = _ecu.Sensors[i] as LocalIdentifier;
            _device.LocalidentifierData = new byte[] { 0x61, (Byte)li.Id, 0x00, 04 };

            Console.WriteLine(string.Format("Testing Sensor: [{0}] {1}", i, _ecu.Sensors[i].Name));
            tsm = _ecu.ReadSensor(_ecu.Sensors[i]);
            Assert.AreEqual("True", tsm.Status);
            Assert.AreEqual(1, tsm.Measurement);

            _device.LocalidentifierData = new byte[] { 0x61, (Byte)li.Id, 0x00, 00 };

            tsm = _ecu.ReadSensor(_ecu.Sensors[i]);
            Assert.AreEqual("False", tsm.Status);
            Assert.AreEqual(0, tsm.Measurement);

            i++;

            li = _ecu.Sensors[i] as LocalIdentifier;
            _device.LocalidentifierData = new byte[] { 0x61, (Byte)li.Id, 0x00, 08 };

            Console.WriteLine(string.Format("Testing Sensor: [{0}] {1}", i, _ecu.Sensors[i].Name));
            tsm = _ecu.ReadSensor(_ecu.Sensors[i]);
            Assert.AreEqual("True", tsm.Status);
            Assert.AreEqual(1, tsm.Measurement);

            _device.LocalidentifierData = new byte[] { 0x61, (Byte)li.Id, 0x00, 00 };

            tsm = _ecu.ReadSensor(_ecu.Sensors[i]);
            Assert.AreEqual("False", tsm.Status);
            Assert.AreEqual(0, tsm.Measurement);

            i++;

            li = _ecu.Sensors[i] as LocalIdentifier;
            _device.LocalidentifierData = new byte[] { 0x61, (Byte)li.Id, 0x00, 0x10 };

            Console.WriteLine(string.Format("Testing Sensor: [{0}] {1}", i, _ecu.Sensors[i].Name));
            tsm = _ecu.ReadSensor(_ecu.Sensors[i]);
            Assert.AreEqual("True", tsm.Status);
            Assert.AreEqual(1, tsm.Measurement);

            _device.LocalidentifierData = new byte[] { 0x61, (Byte)li.Id, 0x00, 00 };

            tsm = _ecu.ReadSensor(_ecu.Sensors[i]);
            Assert.AreEqual("False", tsm.Status);
            Assert.AreEqual(0, tsm.Measurement);

            i++;

            li = _ecu.Sensors[i] as LocalIdentifier;
            _device.LocalidentifierData = new byte[] { 0x61, (Byte)li.Id, 0x00, 0x20 };

            Console.WriteLine(string.Format("Testing Sensor: [{0}] {1}", i, _ecu.Sensors[i].Name));
            tsm = _ecu.ReadSensor(_ecu.Sensors[i]);
            Assert.AreEqual("True", tsm.Status);
            Assert.AreEqual(1, tsm.Measurement);

            _device.LocalidentifierData = new byte[] { 0x61, (Byte)li.Id, 0x00, 00 };

            tsm = _ecu.ReadSensor(_ecu.Sensors[i]);
            Assert.AreEqual("False", tsm.Status);
            Assert.AreEqual(0, tsm.Measurement);

            i++;

            li = _ecu.Sensors[i] as LocalIdentifier;
            _device.LocalidentifierData = new byte[] { 0x61, (Byte)li.Id, 0x00, 0x40 };

            Console.WriteLine(string.Format("Testing Sensor: [{0}] {1}", i, _ecu.Sensors[i].Name));
            tsm = _ecu.ReadSensor(_ecu.Sensors[i]);
            Assert.AreEqual("True", tsm.Status);
            Assert.AreEqual(1, tsm.Measurement);

            _device.LocalidentifierData = new byte[] { 0x61, (Byte)li.Id, 0x00, 00 };

            tsm = _ecu.ReadSensor(_ecu.Sensors[i]);
            Assert.AreEqual("False", tsm.Status);
            Assert.AreEqual(0, tsm.Measurement);

            i++;

            li = _ecu.Sensors[i] as LocalIdentifier;
            _device.LocalidentifierData = new byte[] { 0x61, (Byte)li.Id, 0x55, 0x0 };

            Console.WriteLine(string.Format("Testing Sensor: [{0}] {1}", i, _ecu.Sensors[i].Name));
            tsm = _ecu.ReadSensor(_ecu.Sensors[i]);
            Assert.AreEqual(6162.432f, tsm.Measurement);

            i++;

            li = _ecu.Sensors[i] as LocalIdentifier;
            _device.LocalidentifierData = new byte[] { 0x61, (Byte)li.Id, 0x00, 0x05 };

            Console.WriteLine(string.Format("Testing Sensor: [{0}] {1}", i, _ecu.Sensors[i].Name));
            tsm = _ecu.ReadSensor(_ecu.Sensors[i]);
            Assert.AreEqual(5, tsm.Measurement);

            i++;

            li = _ecu.Sensors[i] as LocalIdentifier;
            _device.LocalidentifierData = new byte[] { 0x61, (Byte)li.Id, 0x00, 0x01 };

            Console.WriteLine(string.Format("Testing Sensor: [{0}] {1}", i, _ecu.Sensors[i].Name));
            tsm = _ecu.ReadSensor(_ecu.Sensors[i]);
            Assert.AreEqual(40, tsm.Measurement);

            i++;

            li = _ecu.Sensors[i] as LocalIdentifier;
            _device.LocalidentifierData = new byte[] { 0x61, (Byte)li.Id, 0x00, 0x01 };

            Console.WriteLine(string.Format("Testing Sensor: [{0}] {1}", i, _ecu.Sensors[i].Name));
            tsm = _ecu.ReadSensor(_ecu.Sensors[i]);
            Assert.AreEqual(1, tsm.Measurement);

            i++;

            li = _ecu.Sensors[i] as LocalIdentifier;
            _device.LocalidentifierData = new byte[] { 0x61, (Byte)li.Id, 0x55, 0x0 };

            Console.WriteLine(string.Format("Testing Sensor: [{0}] {1}", i, _ecu.Sensors[i].Name));
            tsm = _ecu.ReadSensor(_ecu.Sensors[i]);
            Assert.AreEqual(6162.432f, tsm.Measurement);

            i++;

            li = _ecu.Sensors[i] as LocalIdentifier;
            _device.LocalidentifierData = new byte[] { 0x61, (Byte)li.Id, 0x0, 0x2 };

            Console.WriteLine(string.Format("Testing Sensor: [{0}] {1}", i, _ecu.Sensors[i].Name));
            tsm = _ecu.ReadSensor(_ecu.Sensors[i]);

            Assert.AreEqual(80, tsm.Measurement);

            i++;

            li = _ecu.Sensors[i] as LocalIdentifier;
            _device.LocalidentifierData = new byte[] { 0x61, (Byte)li.Id, 0x0, 0x0 };

            Console.WriteLine(string.Format("Testing Sensor: [{0}] {1}", i, _ecu.Sensors[i].Name));
            tsm = _ecu.ReadSensor(_ecu.Sensors[i]);

            Assert.AreEqual(-33, tsm.Measurement);

            _device.LocalidentifierData = new byte[] { 0x61, (Byte)li.Id, 0x00, 0x55 };

            tsm = _ecu.ReadSensor(_ecu.Sensors[i]);

            Assert.AreEqual(21.8f, tsm.Measurement);


            _device.LocalidentifierData = new byte[] { 0x61, (Byte)li.Id, 0x00, 0xFF };

            tsm = _ecu.ReadSensor(_ecu.Sensors[i]);

            Assert.AreEqual(125, tsm.Measurement);

            i++;

            li = _ecu.Sensors[i] as LocalIdentifier;
            _device.LocalidentifierData = new byte[] { 0x61, (Byte)li.Id, 0x0, 0x0 };

            Console.WriteLine(string.Format("Testing Sensor: [{0}] {1}", i, _ecu.Sensors[i].Name));
            tsm = _ecu.ReadSensor(_ecu.Sensors[i]);

            Assert.AreEqual(-33, tsm.Measurement);

            i++;

            li = _ecu.Sensors[i] as LocalIdentifier;
            _device.LocalidentifierData = new byte[] { 0x61, (Byte)li.Id, 0x0, 0x55 };

            Console.WriteLine(string.Format("Testing Sensor: [{0}] {1}", i, _ecu.Sensors[i].Name));
            tsm = _ecu.ReadSensor(_ecu.Sensors[i]);

            Assert.AreEqual(136, tsm.Measurement);

            i++;

            li = _ecu.Sensors[i] as LocalIdentifier;
            _device.LocalidentifierData = new byte[] { 0x61, (Byte)li.Id, 0x0, 0x55 };

            Console.WriteLine(string.Format("Testing Sensor: [{0}] {1}", i, _ecu.Sensors[i].Name));
            tsm = _ecu.ReadSensor(_ecu.Sensors[i]);

            Assert.AreEqual(14.25, tsm.Measurement);

            i++;

            li = _ecu.Sensors[i] as LocalIdentifier;
            _device.LocalidentifierData = new byte[] { 0x61, (Byte)li.Id, 0x0, 0x55 };

            Console.WriteLine(string.Format("Testing Sensor: [{0}] {1}", i, _ecu.Sensors[i].Name));
            tsm = _ecu.ReadSensor(_ecu.Sensors[i]);

            Assert.AreEqual(129.115f, tsm.Measurement);


            i++;

            li = _ecu.Sensors[i] as LocalIdentifier;
            _device.LocalidentifierData = new byte[] { 0x61, (Byte)li.Id, 0x0, 0x55 };

            Console.WriteLine(string.Format("Testing Sensor: [{0}] {1}", i, _ecu.Sensors[i].Name));
            tsm = _ecu.ReadSensor(_ecu.Sensors[i]);

            Assert.AreEqual(39.865f, tsm.Measurement);

            i++;

            li = _ecu.Sensors[i] as LocalIdentifier;
            _device.LocalidentifierData = new byte[] { 0x61, (Byte)li.Id, 0x0, 0x55 };

            Console.WriteLine(string.Format("Testing Sensor: [{0}] {1}", i, _ecu.Sensors[i].Name));
            tsm = _ecu.ReadSensor(_ecu.Sensors[i]);

            Assert.AreEqual(4250, tsm.Measurement);

            i++;

            li = _ecu.Sensors[i] as LocalIdentifier;
            _device.LocalidentifierData = new byte[] { 0x61, (Byte)li.Id, 0x0, 0x55 };

            Console.WriteLine(string.Format("Testing Sensor: [{0}] {1}", i, _ecu.Sensors[i].Name));
            tsm = _ecu.ReadSensor(_ecu.Sensors[i]);

            Assert.AreEqual(4131.85f, tsm.Measurement);

            i++;

            li = _ecu.Sensors[i] as LocalIdentifier;
            _device.LocalidentifierData = new byte[] { 0x61, (Byte)li.Id, 0x0, 0x55 };

            Console.WriteLine(string.Format("Testing Sensor: [{0}] {1}", i, _ecu.Sensors[i].Name));
            tsm = _ecu.ReadSensor(_ecu.Sensors[i]);

            Assert.AreEqual(1666, tsm.Measurement);

            i++;

            li = _ecu.Sensors[i] as LocalIdentifier;
            _device.LocalidentifierData = new byte[] { 0x61, (Byte)li.Id, 0x0, 0x55 };

            Console.WriteLine(string.Format("Testing Sensor: [{0}] {1}", i, _ecu.Sensors[i].Name));
            tsm = _ecu.ReadSensor(_ecu.Sensors[i]);

            Assert.AreEqual(6.1455f, tsm.Measurement);

            i++;

            li = _ecu.Sensors[i] as LocalIdentifier;
            _device.LocalidentifierData = new byte[] { 0x61, (Byte)li.Id, 0x0, 0x55 };

            Console.WriteLine(string.Format("Testing Sensor: [{0}] {1}", i, _ecu.Sensors[i].Name));
            tsm = _ecu.ReadSensor(_ecu.Sensors[i]);

            Assert.AreEqual(85, tsm.Measurement);

            i++;

            li = _ecu.Sensors[i] as LocalIdentifier;
            _device.LocalidentifierData = new byte[] { 0x61, (Byte)li.Id, 0x0, 0x55 };

            Console.WriteLine(string.Format("Testing Sensor: [{0}] {1}", i, _ecu.Sensors[i].Name));
            tsm = _ecu.ReadSensor(_ecu.Sensors[i]);

            Assert.AreEqual(0.149093136f, tsm.Measurement);

            i++;

            li = _ecu.Sensors[i] as LocalIdentifier;
            _device.LocalidentifierData = new byte[] { 0x61, (Byte)li.Id, 0x0, 0x02 };

            Console.WriteLine(string.Format("Testing Sensor: [{0}] {1}", i, _ecu.Sensors[i].Name));
            tsm = _ecu.ReadSensor(_ecu.Sensors[i]);
            Assert.AreEqual("Idle", tsm.Status);
            Assert.AreEqual(1, tsm.Measurement);

            _device.LocalidentifierData = new byte[] { 0x61, (Byte)li.Id, 0x00, 0x0 };

            tsm = _ecu.ReadSensor(_ecu.Sensors[i]);
            Assert.AreEqual("Mid", tsm.Status);
            Assert.AreEqual(0, tsm.Measurement);

            i++;

            li = _ecu.Sensors[i] as LocalIdentifier;
            _device.LocalidentifierData = new byte[] { 0x61, (Byte)li.Id, 0x0, 0x00 };

            Console.WriteLine(string.Format("Testing Sensor: [{0}] {1}", i, _ecu.Sensors[i].Name));
            tsm = _ecu.ReadSensor(_ecu.Sensors[i]);
            Assert.AreEqual("InActive", tsm.Status);
            Assert.AreEqual(0, tsm.Measurement);

            _device.LocalidentifierData = new byte[] { 0x61, (Byte)li.Id, 0x0, 0x04 };
            tsm = _ecu.ReadSensor(_ecu.Sensors[i]);
            Assert.AreEqual("Active", tsm.Status);
            Assert.AreEqual(1, tsm.Measurement);

            i++;

            li = _ecu.Sensors[i] as LocalIdentifier;
            _device.LocalidentifierData = new byte[] { 0x61, (Byte)li.Id, 0x0, 0x00 };

            Console.WriteLine(string.Format("Testing Sensor: [{0}] {1}", i, _ecu.Sensors[i].Name));
            tsm = _ecu.ReadSensor(_ecu.Sensors[i]);
            Assert.AreEqual("InActive", tsm.Status);
            Assert.AreEqual(0, tsm.Measurement);

            _device.LocalidentifierData = new byte[] { 0x61, (Byte)li.Id, 0x0, 0x08 };
            tsm = _ecu.ReadSensor(_ecu.Sensors[i]);
            Assert.AreEqual("Active", tsm.Status);
            Assert.AreEqual(1, tsm.Measurement);

            i++;

            li = _ecu.Sensors[i] as LocalIdentifier;
            _device.LocalidentifierData = new byte[] { 0x61, (Byte)li.Id, 0x0, 0x00 };

            Console.WriteLine(string.Format("Testing Sensor: [{0}] {1}", i, _ecu.Sensors[i].Name));
            tsm = _ecu.ReadSensor(_ecu.Sensors[i]);
            Assert.AreEqual("InActive", tsm.Status);
            Assert.AreEqual(0, tsm.Measurement);

            _device.LocalidentifierData = new byte[] { 0x61, (Byte)li.Id, 0x0, 0x20 };
            tsm = _ecu.ReadSensor(_ecu.Sensors[i]);
            Assert.AreEqual("Active", tsm.Status);
            Assert.AreEqual(1, tsm.Measurement);

            i++;

            li = _ecu.Sensors[i] as LocalIdentifier;
            _device.LocalidentifierData = new byte[] { 0x61, (Byte)li.Id, 0x0, 0x00 };

            Console.WriteLine(string.Format("Testing Sensor: [{0}] {1}", i, _ecu.Sensors[i].Name));
            tsm = _ecu.ReadSensor(_ecu.Sensors[i]);
            Assert.AreEqual("InActive", tsm.Status);
            Assert.AreEqual(0, tsm.Measurement);

            _device.LocalidentifierData = new byte[] { 0x61, (Byte)li.Id, 0x0, 0x40 };
            tsm = _ecu.ReadSensor(_ecu.Sensors[i]);
            Assert.AreEqual("Active", tsm.Status);
            Assert.AreEqual(1, tsm.Measurement);

            i++;

            li = _ecu.Sensors[i] as LocalIdentifier;
            _device.LocalidentifierData = new byte[] { 0x61, (Byte)li.Id, 0x0, 0x00 };

            Console.WriteLine(string.Format("Testing Sensor: [{0}] {1}", i, _ecu.Sensors[i].Name));
            tsm = _ecu.ReadSensor(_ecu.Sensors[i]);
            Assert.AreEqual("InActive", tsm.Status);
            Assert.AreEqual(0, tsm.Measurement);

            _device.LocalidentifierData = new byte[] { 0x61, (Byte)li.Id, 0x0, 0x80 };
            tsm = _ecu.ReadSensor(_ecu.Sensors[i]);
            Assert.AreEqual("Active", tsm.Status);
            Assert.AreEqual(1, tsm.Measurement);

            i++;

            li = _ecu.Sensors[i] as LocalIdentifier;
            _device.LocalidentifierData = new byte[] { 0x61, (Byte)li.Id, 0x0, 0x01 };

            Console.WriteLine(string.Format("Testing Sensor: [{0}] {1}", i, _ecu.Sensors[i].Name));
            tsm = _ecu.ReadSensor(_ecu.Sensors[i]);
            Assert.AreEqual("S.C to Gnd/Sensor lower limit", tsm.Status);
            Assert.AreEqual(1, tsm.Measurement);

            _device.LocalidentifierData = new byte[] { 0x61, (Byte)li.Id, 0x0, 0x02 };
            tsm = _ecu.ReadSensor(_ecu.Sensors[i]);
            Assert.AreEqual("Lean", tsm.Status);
            Assert.AreEqual(2, tsm.Measurement);

            _device.LocalidentifierData = new byte[] { 0x61, (Byte)li.Id, 0x0, 0x03 };
            tsm = _ecu.ReadSensor(_ecu.Sensors[i]);
            Assert.AreEqual("Cold or Open Circuit", tsm.Status);
            Assert.AreEqual(3, tsm.Measurement);

            _device.LocalidentifierData = new byte[] { 0x61, (Byte)li.Id, 0x0, 0x04 };
            tsm = _ecu.ReadSensor(_ecu.Sensors[i]);
            Assert.AreEqual("Rich", tsm.Status);
            Assert.AreEqual(4, tsm.Measurement);

            _device.LocalidentifierData = new byte[] { 0x61, (Byte)li.Id, 0x0, 0x05 };
            tsm = _ecu.ReadSensor(_ecu.Sensors[i]);
            Assert.AreEqual("S.C to Vbat/Sensor upper limit", tsm.Status);
            Assert.AreEqual(5, tsm.Measurement);

            i++;

            li = _ecu.Sensors[i] as LocalIdentifier;
            _device.LocalidentifierData = new byte[] { 0x61, (Byte)li.Id, 0x0, 0x0A };

            Console.WriteLine(string.Format("Testing Sensor: [{0}] {1}", i, _ecu.Sensors[i].Name));
            tsm = _ecu.ReadSensor(_ecu.Sensors[i]);

            Assert.AreEqual(100, tsm.Measurement);

            i++;

            li = _ecu.Sensors[i] as LocalIdentifier;
            _device.LocalidentifierData = new byte[] { 0x61, (Byte)li.Id, 0x0, 0x0A };

            Console.WriteLine(string.Format("Testing Sensor: [{0}] {1}", i, _ecu.Sensors[i].Name));
            tsm = _ecu.ReadSensor(_ecu.Sensors[i]);

            Assert.AreEqual(3.89999986f, tsm.Measurement);

            i++;

            li = _ecu.Sensors[i] as LocalIdentifier;
            _device.LocalidentifierData = new byte[] { 0x61, (Byte)li.Id, 0x0, 0x0A };

            Console.WriteLine(string.Format("Testing Sensor: [{0}] {1}", i, _ecu.Sensors[i].Name));
            tsm = _ecu.ReadSensor(_ecu.Sensors[i]);

            Assert.AreEqual(0.099999994f, tsm.Measurement);

            i++;

            li = _ecu.Sensors[i] as LocalIdentifier;
            _device.LocalidentifierData = new byte[] { 0x61, (Byte)li.Id, 0x2, 0x00 };

            Console.WriteLine(string.Format("Testing Sensor: [{0}] {1}", i, _ecu.Sensors[i].Name));
            tsm = _ecu.ReadSensor(_ecu.Sensors[i]);

            Assert.AreEqual(4, tsm.Measurement);

            i++;

            li = _ecu.Sensors[i] as LocalIdentifier;
            _device.LocalidentifierData = new byte[] { 0x61, (Byte)li.Id, 0x2, 0x00 };

            Console.WriteLine(string.Format("Testing Sensor: [{0}] {1}", i, _ecu.Sensors[i].Name));
            tsm = _ecu.ReadSensor(_ecu.Sensors[i]);

            Assert.AreEqual(1494220.75f, tsm.Measurement);

            i++;

            li = _ecu.Sensors[i] as LocalIdentifier;
            _device.LocalidentifierData = new byte[] { 0x61, (Byte)li.Id, 0x2, 0x00 };

            Console.WriteLine(string.Format("Testing Sensor: [{0}] {1}", i, _ecu.Sensors[i].Name));
            tsm = _ecu.ReadSensor(_ecu.Sensors[i]);

            Assert.AreEqual(4, tsm.Measurement);

            i++;

            li = _ecu.Sensors[i] as LocalIdentifier;
            _device.LocalidentifierData = new byte[] { 0x61, (Byte)li.Id, 0x2, 0x00 };

            Console.WriteLine(string.Format("Testing Sensor: [{0}] {1}", i, _ecu.Sensors[i].Name));
            tsm = _ecu.ReadSensor(_ecu.Sensors[i]);

            Assert.AreEqual(4, tsm.Measurement);

            i++;

            li = _ecu.Sensors[i] as LocalIdentifier;
            _device.LocalidentifierData = new byte[] { 0x61, (Byte)li.Id, 0x2, 0x00 };

            Console.WriteLine(string.Format("Testing Sensor: [{0}] {1}", i, _ecu.Sensors[i].Name));
            tsm = _ecu.ReadSensor(_ecu.Sensors[i]);

            Assert.AreEqual(4, tsm.Measurement);

            i++;

            li = _ecu.Sensors[i] as LocalIdentifier;
            _device.LocalidentifierData = new byte[] { 0x61, (Byte)li.Id, 0x2, 0x00 };

            Console.WriteLine(string.Format("Testing Sensor: [{0}] {1}", i, _ecu.Sensors[i].Name));
            tsm = _ecu.ReadSensor(_ecu.Sensors[i]);

            Assert.AreEqual(5120, tsm.Measurement);

            i++;

            li = _ecu.Sensors[i] as LocalIdentifier;
            _device.LocalidentifierData = new byte[] { 0x61, (Byte)li.Id, 0x2, 0x00 };

            Console.WriteLine(string.Format("Testing Sensor: [{0}] {1}", i, _ecu.Sensors[i].Name));
            tsm = _ecu.ReadSensor(_ecu.Sensors[i]);

            Assert.AreEqual(240.128006f, tsm.Measurement);

            i++;


            li = _ecu.Sensors[i] as LocalIdentifier;
            _device.LocalidentifierData = new byte[] { 0x61, (Byte)li.Id, 0x2, 0x00 };

            Console.WriteLine(string.Format("Testing Sensor: [{0}] {1}", i, _ecu.Sensors[i].Name));
            tsm = _ecu.ReadSensor(_ecu.Sensors[i]);

            Assert.AreEqual(10.2399998f, tsm.Measurement);

            i++;

            li = _ecu.Sensors[i] as LocalIdentifier;
            _device.LocalidentifierData = new byte[] { 0x61, (Byte)li.Id, 0x2, 0x00 };

            Console.WriteLine(string.Format("Testing Sensor: [{0}] {1}", i, _ecu.Sensors[i].Name));
            tsm = _ecu.ReadSensor(_ecu.Sensors[i]);

            Assert.AreEqual(10.2399998f, tsm.Measurement);

        }



        [Test]
        public void TestActuators()
        {
            Assert.AreEqual(15, _ecu.Actuators.Count);

            InputOutputLocalIdentifier ioli = _ecu.Actuators[0] as InputOutputLocalIdentifier;

            Assert.AreEqual(0, ioli.ControlParameter);
            Assert.AreEqual(5, ioli.Duration);
            Assert.AreEqual(1, ioli.Id);
            Assert.AreEqual("INJ.BMP", ioli.ImageName);
            Assert.AreEqual(ActuatorActivationType.Ecu, ioli.ActivationType);
            Assert.AreEqual("Injector 1 will switch @ 1ms for 5 seconds.", ioli.Message);
            Assert.AreEqual("Injector 1", ioli.Name);
            Assert.AreEqual(true, ioli.ReturnEcuControl);
            Assert.AreEqual(false, ioli.UseControlParameters);
            Assert.AreEqual(string.Format("Warning this test causes {0} to inject petrol. Continue ?.", ioli.Name), ioli.Warning);

            ioli = _ecu.Actuators[13] as InputOutputLocalIdentifier;

            Assert.AreEqual(0, ioli.ControlParameter);
            Assert.AreEqual(0, ioli.Duration);
            Assert.AreEqual(253, ioli.Id);
            Assert.AreEqual("THROT.bmp", ioli.ImageName);
            Assert.AreEqual(ActuatorActivationType.Reset, ioli.ActivationType);
            Assert.AreEqual("The Idle Speed Controller will be reset. The Ecus self adaptive parameters will be reset. This requires a Key-off then wait 90 seconds then a Key-On to complete the procedure.", ioli.Message);
            Assert.AreEqual("Reset Idle Speed Controller", ioli.Name);
            Assert.AreEqual(false, ioli.ReturnEcuControl);
            Assert.AreEqual(false, ioli.UseControlParameters);
            Assert.AreEqual("The Idle Speed Controller will be reset. Continue?", ioli.Warning);
        }

        [Test]
        public void TestPerformanceMeasurment()
        {
            Assert.AreNotEqual(null, _ecu.SpeedSensor);
            Assert.AreNotEqual(null, _ecu.RpmSensor);
        }

    }
}
